//
//  HWTopicsSpecialTableViewCell.m
//  HappyWeekend
//
//  Created by 赵洁 on 16/1/12.
//  Copyright © 2016年 com.mjykj.www. All rights reserved.
//

#import "HWTopicsSpecialTableViewCell.h"
#import "HWTopicsBannerModel.h"
#define kgap 10 //jianju
@implementation HWTopicsSpecialTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _specialLable = [[UILabel alloc]initWithFrame:CGRectMake(kgap,0, kScreenWidth/5, kgap*3)];
        _specialLable.font = [UIFont systemFontOfSize:16];
        _specialLable.numberOfLines= 0;
        _specialLable.text = @"专题合集";
        [self.contentView addSubview:_specialLable];
        _findAllButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _findAllButton.frame = CGRectMake(kScreenWidth - kgap*9, _specialLable.top+2, kScreenWidth/3-kgap*3, _specialLable.height);
        _findAllButton.layer.cornerRadius = 10;
        [_findAllButton setTitle:@"查看全部" forState:(UIControlStateNormal)];
        [_findAllButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        //_findAllButton.backgroundColor = [UIColor purpleColor];
        [self.contentView addSubview:_findAllButton];
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(kgap, _specialLable.bottom+kgap, kScreenWidth, 70)];
        
        _scrollView.alwaysBounceHorizontal = YES;
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.showsVerticalScrollIndicator = NO;
//        _scrollView.pagingEnabled = YES;
        _scrollView.bounces =NO;
        _scrollView.contentSize = CGSizeMake(135*4, 0);
        [self.contentView addSubview:_scrollView];
        for (int i = 0; i < 4; i ++) {
            UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
            button.frame = CGRectMake( i *(kScreenWidth/2.5) , 0, kScreenWidth/3, _scrollView.height);
            button.tag = 100+i;
           // button.backgroundColor = [UIColor redColor];
            button.layer.cornerRadius = 15;
            button.layer.masksToBounds = YES;
            [_scrollView addSubview:button];
            
            
        
        }
    }
    return self;
}
- (void)setArray:(NSArray *)array
{
    _array = array;
    for (int i = 0; i < 4; i++) {
        HWTopicsBannerModel *model = array[i];
        UIButton *but = [_scrollView viewWithTag:100+i];
        [but sd_setBackgroundImageWithURL:[NSURL URLWithString:model.banner_image_url] forState:(UIControlStateNormal)];
    }
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
